//
//  DrawView.m
//  DrawText
//
//  Created by ks on 2017/4/28.
//  Copyright © 2017年 Ls. All rights reserved.
//

#define radiu 80  //半径
#define PI 3.1415926

#import "DrawView.h"

@implementation DrawView

- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
   
    UIBezierPath *polygon = [UIBezierPath bezierPath];
  
   
    [polygon moveToPoint:CGPointMake(100, 20)];
    [polygon addLineToPoint:CGPointMake(100+radiu*cos(18*PI/180), 100-radiu*sin(18*PI/180))];
    [polygon addLineToPoint:CGPointMake(100+radiu*sin(36*PI/180), 100+radiu*cos(36*PI/180))];
    [polygon addLineToPoint:CGPointMake(100-radiu*sin(36*PI/180), 100+radiu*cos(36*PI/180))];
    [polygon addLineToPoint:CGPointMake(100-radiu*cos(18*PI/180), 100-radiu*sin(18*PI/180))];
    
    [[UIColor cyanColor] setFill];
    
    [polygon fill];
    
    [[UIColor redColor] set]; //设置线条颜色
    UIBezierPath* aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 100)
                                                         radius:radiu
                                                     startAngle:0
                                                       endAngle:360
                                                      clockwise:YES];
    aPath.lineWidth = 2.0;
    [aPath stroke];
    
    [[UIColor whiteColor] set];
    UIBezierPath *path1 = [UIBezierPath bezierPath];
    [path1 moveToPoint:CGPointMake(100 , 100)];
    [path1 addLineToPoint:CGPointMake(100+radiu*cos(18*PI/180), 100-radiu*sin(18*PI/180))];
    [path1 stroke];
    
    UIBezierPath *path2 = [UIBezierPath bezierPath];
    [path2 moveToPoint:CGPointMake(100 , 100)];
    [path2 addLineToPoint:CGPointMake(100+radiu*sin(36*PI/180), 100+radiu*cos(36*PI/180))];
    [path2 stroke];
    
    UIBezierPath *path3 = [UIBezierPath bezierPath];
    [path3 moveToPoint:CGPointMake(100 , 100)];
    [path3 addLineToPoint:CGPointMake(100-radiu*sin(36*PI/180), 100+radiu*cos(36*PI/180))];
    [path3 stroke];
    
    UIBezierPath *path4 = [UIBezierPath bezierPath];
    [path4 moveToPoint:CGPointMake(100 , 100)];
    [path4 addLineToPoint:CGPointMake(100-radiu*cos(18*PI/180), 100-radiu*sin(18*PI/180))];
    [path4 stroke];
    
    UIBezierPath *path5 = [UIBezierPath bezierPath];
    [path5 moveToPoint:CGPointMake(100 , 100)];
    [path5 addLineToPoint:CGPointMake(100,20)];
    [path5 stroke];
    
    [self pingfen];
}


-(void)pingfen{
    UIBezierPath *polygon = [UIBezierPath bezierPath];
  
    
    float proportion_1=[self.proportionArray[0] floatValue];
    float proportion_2=[self.proportionArray[1] floatValue];
    float proportion_3=[self.proportionArray[2] floatValue];
    float proportion_4=[self.proportionArray[3] floatValue];
    float proportion_5=[self.proportionArray[4] floatValue];
    
    CGPoint a;
    CGPoint b;
    CGPoint c;
    CGPoint d;
    CGPoint e;
    
    a=CGPointMake(100, proportion_1*80);
    b=CGPointMake(100+radiu*cos(18*PI/180)*proportion_2, 100-radiu*sin(18*PI/180)*proportion_2);
    c=CGPointMake(100+radiu*sin(36*PI/180)*proportion_3, 100+radiu*cos(36*PI/180)*proportion_3);
    d=CGPointMake(100-radiu*sin(36*PI/180)*proportion_4, 100+radiu*cos(36*PI/180)*proportion_4);
    e=CGPointMake(100-radiu*cos(18*PI/180)*proportion_5, 100-radiu*sin(18*PI/180)*proportion_5);
    
    
    [polygon moveToPoint:a];
    [polygon addLineToPoint:b];
    [polygon addLineToPoint:c];
    [polygon addLineToPoint:d];
    [polygon addLineToPoint:e];
    [polygon addLineToPoint:a];
    
    [[UIColor purpleColor] setFill];
    [polygon fillWithBlendMode:(kCGBlendModeNormal) alpha:0.5];
    
}













@end
